#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
using namespace std;

int N, M;
bool check[100][100];
int dx[4] = { 1,-1,0,0 };
int dy[4] = { 0,0,1,-1 };

bool dfs(int r, int c, vector<string>& Maze)
{
    if (Maze[r][c] == 'T')
        return true;
    for (int k = 0; k < 4; k++)
    {
        int x = r + dx[k];
        int y = c + dy[k];
        if (x >= 0 && x < N && y >= 0 && y < M && !check[x][y] && Maze[x][y] != '#')
        {
            check[x][y] = true;
            if (dfs(x, y, Maze))
                return true;
        }
    }
    return false;
}

int main()
{
    while (cin >> N >> M)
    {
        vector<string> Maze(N);
        for (int i = 0; i < N; i++)
        {
            cin >> Maze[i];
        }

        //weizhM
        int sr, sc;
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < M; j++)
            {
                if (Maze[i][j] == 'S')
                {
                    sr = i;
                    sc = j;
                }
                check[i][j] = false;
            }
        }

        check[sr][sc] = true;
        if (dfs(sr, sc, Maze))
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
}